$('#reset').click(function(){
    $('input').val('');
})
var dataSource = new Array();
//table的数据源
var table;   //table对象
dataSource = [];


jQuery.Huitab = function (tabBar, tabCon, class_name, tabEvent, i) {
    var $tab_menu = $(tabBar);
    // 初始化操作
    $tab_menu.removeClass(class_name);
    $(tabBar).eq(i).addClass(class_name);
    $(tabCon).hide();
    $(tabCon).eq(i).show();
    $tab_menu.bind(tabEvent, function () {
        $tab_menu.removeClass(class_name);
        $(this).addClass(class_name);
        var index = $tab_menu.index(this);
        $(tabCon).hide();
        $(tabCon).eq(index).show();
    });
}

$(function () {
    $.Huitab("#tab_goods .tabBar span", "#tab_goods .tabCon", "current", "click", "0")
});
// #tab_demo 父级id
// #tab_demo .tabBar span 控制条
// #tab_demo .tabCon 内容区
// click 事件 点击切换，可以换成mousemove 移动鼠标切换
// 1	默认第2个tab为当前状态（从0开始）

$(function () {
    $('.skin-minimal input').iCheck({
        checkboxClass: 'icheckbox-blue',
        radioClass: 'iradio-blue',
        increaseArea: '20%'
    })
});

var customerId =""
var loginAccout=sessionStorage.getItem("loginAccout");
var ids=""
var memberid=sessionStorage.getItem("memberid")
if(sessionStorage.getItem("ids")=="null"){
    ids=""
}else {
    ids=sessionStorage.getItem("ids")
}
if(sessionStorage.getItem("customerId")=="null"){
    customerId =""
}else {
    customerId =sessionStorage.getItem("customerId")
}
$.ajax({
   /* root.member.viewCustAccount*/
    url: root.member.queryCustomerMsg,
    cache: false,  //禁用缓存
    type: "POST",
    dataType:'json',
    contentType: "application/json",
    data: JSON.stringify({
        "loginAccout":loginAccout,
        "customerId":customerId,
        "accountRelationInfoId":ids,
        "memberId":memberid
    }),
    success: function (data) {
        console.log(data);
        //描述
        $('#mainCustomerName').html(data.data.mainCustomerName);
        $('#customerId').html(data.data.customerId);
        $('#customerName').html(data.data.customerName);
        $('#groupName').html(data.data.groupName);
        if(data.data.bindMobile==10){
            $('#moblie').html(data.data.mobile);
        }else {
            $('#moblie').html("");
        }

        $('#userName').html(data.data.userName);

            $('#aright').html(data.data.aright);

        $('#createTime').html(data.data.createTime);
        $('#loginAccount').html(data.data.loginAccount);
        if(data.data.list!=""){
            contractCustomer(data.data.list)
        }

    },
    error: function () {
        $.Huimodalalert('失败！');
    }
});


function contractCustomer(data) {
    for (let i=0;i<data.length;i++) {
        var level2Html = '';
        var approveSeqs=""
        var isApproves=""

            for (let j=0;j<data[i].length;j++) {
                if(data[i][j].approveSeq==0){
                    approveSeqs="否"
                }else {
                    approveSeqs= data[i][j].approveSeq
                }
                if(data[i][j].isApprove==20){
                    isApproves="是"
                }else {
                    isApproves= "否"
                }
                if (j==0){
                    level2Html='<tr class="customertr">' +
                        '                            <td style="border-right: 1px solid #dedede;">' + data[i][j].customerName + '</td>' +
                        '                               <td>' + data[i][j].orderAccountDto + '</td>' +
                        '                                    <td>' + data[i][j].approveAccountDtos + '</td>' +
                        '                                    <td>' + approveSeqs + '</td>' +
                        '                                    <td>' + isApproves + '</td>' +
                        '                                     <td>' + data[i][j].settleAccountDto + '</td>' +
                        '                                </tr>'

                } else{
                    level2Html+='<tr class="level2-box" >' +
                        '                               <td style="border-right: 1px solid #dedede;border-top: 2px solid #dedede00;"></td>' +
                        '                                   <td></td>' +
                        '                                    <td>' + data[i][j].approveAccountDtos + '</td>' +
                        '                                    <td>' + approveSeqs + '</td>' +
                        '                                    <td>' + isApproves + '</td>' +
                        '                                            <td></td>' +
                        '                                        </tr>';
                }



            }

        $(".customer-tbody").append(level2Html)


    }


}



